const CompressionWebpackPlugin = require('compression-webpack-plugin');

module.exports = {
  productionSourceMap: false,
  transpileDependencies: ['element-ui', 'ele-admin', 'vue-i18n'],
  chainWebpack: (config) => {
    config.plugins.delete('prefetch');
    if (process.env.NODE_ENV !== 'development') {
      // 对超过10kb的文件gzip压缩
      config.plugin('compressionPlugin').use(new CompressionWebpackPlugin({
        test: /\.(js|css|html)$/,
        threshold: 10240
      }));
    }
  },
  devServer: {
    port: 8082, // 端口号
    // host: "localhost",
    host:'0.0.0.0', //域名 0.0.0.0局域网可访问
    disableHostCheck: true,// 解决域名访问本地运行地址时出现Invalid Host header的问题
    useLocalIp: true,
    https: false, // https:{type:Boolean}
    open: true, //配置自动启动浏览器
    // proxy: 'http://localhost:4000' // 配置跨域处理,只有一个代理
    proxy: {
      "/api": {
        target: "http://winsdom.com/",
        ws: true,
        changeOrigin: true,
        pathRewrite: {
          "/api": ""
        }
      },
    }, // 配置多个代理
  },
  css: {
    loaderOptions: {
      sass: {
        sassOptions: {
          outputStyle: 'expanded'
        }
      }
    }
  }
}
